﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CrystalDecisions.Enterprise;
using CrystalDecisions.Enterprise.Desktop;

namespace BO.Management
{
    public class ContentGenericProvider:BaseInfoObjectProvider<CrystalDecisions.Enterprise.InfoObject>
    {

        /// <summary>
        /// Default constructor required the LogonProvider used to connect to BO Cms
        /// </summary>
        /// <param name="logonProvider"></param>
        public ContentGenericProvider(LogonProvider logonProvider)
            : base(logonProvider)
        {
           
        }
        public override ObjectKind Kind
        {
            get { return ObjectKind.Generic; }
        }

        /// <summary>
        /// Get the full path of a boObject
        /// </summary>
        /// <param name="boObject"></param>
        /// <returns></returns>
        public BOPathInformation GetFullPath(InfoObject boObject)
        {

            if (boObject.Kind == Enum.GetName(typeof(ObjectKind), ObjectKind.Folder))
            {
                return ContentFolderProvider.GetFullPath((Folder)boObject);
            }

            BOPathInformation info = new BOPathInformation();
            info.Id = boObject.ID;

            //Get the Folder full path of this object
            Folder folder = (Folder)this.GetObject((Int32)boObject.Properties["SI_PARENT_FOLDER"].Value);
            BOPathInformation folderPath = ContentFolderProvider.GetFullPath(folder);

            info.Name = boObject.Title;
            info.FullPath = String.Concat(folderPath.FullPath, @"\", boObject.Title);
            info.LastUpdated = boObject.GetUpdateTimeStamp();

            return info;
        }


    }
}
